<template>
  <div>
    <group>
      <div>
      <x-table :cell-bordered="false" :content-bordered="false" style="background-color:#fff;">
        <thead>
          <tr style="background-color: #F7F7F7">
            <th>时间</th>
            <th>自评分</th>
            <th>组长审核分</th>
          </tr>
        </thead>
        <tbody v-for="(data,index) in historyList">
          <tr>
            <td><span>{{data.year}}</span><span>-</span><span>{{data.month>9?data.month:'0'+data.month}}</span></td>
            <td style="padding:2px 25px 2px 2px;text-align:right">{{data.self_score}}</td>
            <td style="padding:2px 55px 2px 2px;text-align:right">
              <router-link :to="'/tabbar/pfs?staffId='+staffId+'&year='+data.year+'&month='+data.month">
                <span v-if="data.tlScore!=null">{{data.tlScore}}</span>
                <span v-else="data.tlScore==null">待审批</span>
              </router-link>
            </td>
          </tr>
        </tbody>
      </x-table>
      </div>
    </group> 
  </div>
</template>

<script>
  import { GroupTitle, Group, Cell, XInput, XButton, XTable} from 'vux'

  export default {
    components: {
      Group,
      GroupTitle,
      Cell,
      XInput,
      XButton,
      XTable
    },
    data () {
      var staffIdOnLogin = localStorage.getItem('ms_staffId')
      return {
        staffId: staffIdOnLogin,
        historyList: []
      }
    },
  mounted: function () {
    this.getData()
  },
  methods: {
    getData: function (value) {
      var self = this
      self.$ajax({
        method: 'get',
        url: '../wx/performance/history',
        params: {
          staffId: self.staffId
        }
      })
      .then(function (res) {
        console.log(res)
        self.historyList = res.data
      })
      .catch(function (err) {
        console.log(err)
      })
    }
    }
  }
</script>
